<? 
session_start();
require("connectDB.php");

$strSql = "select * from user_account where username='$uid' and password='$upwd'";
$temp = mysql_query($strSql);

if (mysql_num_rows($temp)==1){
$_SESSION["login"]=$uid;
while($row=mysql_fetch_array($temp)){
$_SESSION["ses_name"]=$row["name"];
$_SESSION["ses_id"]=$row["user_id"];
$id=$row["user_id"];
$slogin=$row["status_login"]+1;
mysql_query("UPDATE user_account SET status_login='$slogin' where user_id='$id'");
switch($row["type"]){
case "A":
?> <meta http-equiv="refresh" content="0;url=Admin.php"> <? break;
case "S":
?> <meta http-equiv="refresh" content="0;url=Student.php"> <? break;
case "T":
?> <meta http-equiv="refresh" content="0;url=Teacher.php"> <? break;

}}}
else{
echo "<script language='javascript'>alert('Login not pass please try again');</script>";?> <meta http-equiv="refresh" content="0;url=HomeIndex.php"> <?
}
mysql_free_result($temp);
mysql_close($con);

?>